<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String login_id = null;
String user_id = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
}


String search_combo 	= CommonUtil.nvl(request.getParameter("search_combo"),"");
String keyword 		= CommonUtil.nvl(request.getParameter("keyword"),"");
String line_number	= CommonUtil.nvl(request.getParameter("line_number"),"10");
//페이징 처리 Start
//페이지 표시정보 받기 혹은 검색입력창
String curr_page = CommonUtil.nvl(request.getParameter("curr_page"),"1");

String one_group = CommonUtil.nvl(request.getParameter("one_group"),"10");
String total_count = CommonUtil.nvl(request.getParameter("total_count"),"0");
//페이징 처리 End

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;


String seq 		= "";
String grade 		= "";
String exam_num 		= "";
String level_code 		= "";
String level_name 		= "";
String testlet 		= "";
String reg_dt	= "";
String r_num="";


if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
}

if(list != null){
	if(list.size() > 0){
		total_count = (String)((HashMap)list.get(0)).get("total_row");
		System.out.println("total_count ========> " + total_count);
	}
}

if(list.size() == 0){
	total_count = "0";
}

%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/ajaxutil.js"></script>
<script>
function go_input(){
	var frm = document.mainform;
	
	if(frm.grade.value == ''){
		alert('등급을 선택하세요.');
		frm.grade.focus();
		return;
	}
	
	if(frm.exam_num.value == ''){
		alert('문제번호를 입력하세요.');
		frm.exam_num.focus();
		return;
	}
	
	if(frm.level_code.value == ''){
		alert('난이도를 선택하세요.');
		frm.level_code.focus();
		return;
	}
	
	if(frm.seq.value != ''){
		frm.cmd.value='grade_modify';
	}else{
		frm.cmd.value='grade_insert';
	}
	
	frm.action = '/speaking.pb';
	frm.target= 'hidden_frm';  	            
	frm.submit();	
}

function go_modify(ad){
	var frm = document.mainform;
	frm.seq.value= ad
	
	frm.cmd.value='grade_select';
	frm.target= 'hidden_frm';  
	frm.action = '/speaking.pb';	           
	frm.submit();	
}

function go_delete(ad){
	var frm = document.mainform;	
	frm.seq.value= ad
	
	if(confirm('삭제하시겠습니까?')){
		frm.cmd.value='grade_delete';
		frm.action = '/speaking.pb';
		frm.target= 'hidden_frm';              
		frm.submit();	
	}
}

function go_grade(){
	var frm = document.mainform;	
	frm.cmd.value='grade_main';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();	
}


//검색
function go_search(){
	var frm = document.mainform;
	
	if(frm.search_combo.value==''){
		alert('검색구분을 선택하세요.');
		return;
	}
	frm.cmd.value='grade_main';
	frm.curr_page.value ="1";
	frm.total_count.value="0";
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

// 페이지 번호를 눌렸을때.
function go_page(page){
	var frm = document.mainform;
	frm.cmd.value='grade_main';
	frm.curr_page.value = page ;			
	frm.total_count.value = "<%=total_count%>";
	frm.keyword.value = "<%=keyword%>";
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

function init_grade(){
	form = document.mainform;
	
	setSPSelect(form.level_code,'', '난이도선택', 'level');
    
}


window.onload = init_grade;
</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>
<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="level_main" /><jsp:param name="submenu_idx" value="4" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" >
	<div id="bodyContainer">
        <div id="contents">
         <!-- 
          <div class="select_menu">
            <ul>              
              <li><select name="search_combo" id="search_combo">
                <option value=''>선택</option>
                <option value=1>이름</option>
                <option value=2>등급</option>
              </select></li>
              <li><input type="text" name="keyword" id="keyword" style="width:200px"/></li>
              <li><a href="#" onclick="go_search()"><img src="/img/btn_search.gif" alt="search" /></a></li>
              <p class="a_r"><a href="#"><img src="/img/btn_excel.gif" alt="excel" /></a></p>
            </ul>
          </div>
          -->
          <input type='hidden' name="search_combo">
          <input type='hidden' name="keyword">
          <div class="boxContainer">
            <dl title="등급별 문제난이도목록">
              <dt>등급별 문제난이도 등록/수정/삭제</dt>
            </dl>
            <table class="levelTb">
              <tr>              
                <th>등급 </th>
                <td><input name="seq" type="hidden" id="seq" style="width:80px" />
                	<select name="grade" id="grade" style="width:80px">
                		<option value="">등급선택</option>
                		<option value="LOW">LOW</option>
                		<option value="MEDIUM">MEDIUM</option>
                		<option value="HIGH">HIGH</option>
                	</select>
                </td>
                <th>문제번호</th>
                <td><input name="exam_num" type="text" id="exam_num" style="width:50px" /></td>
                <th>난이도</th>
                <td><select name="level_code" id="level_code" style="width:80px">
                  <option value=''>난이도</option>                 
                </select></td>
                <th>Testlet </th>
                <td>
                	<select name="testlet" id="testlet" style="width:80px">
                		<option value="">testlet선택</option>
                		<option value="1">1</option>
                		<option value="2">2</option>
                		<option value="3">3</option>
                		<option value="4">4</option>
                		<option value="5">5</option>
                		<option value="6">6</option>
                		<option value="7">7</option>
                		<option value="8">8</option>
                		<option value="9">9</option>
                		<option value="10">10</option>
                	</select>
                </td>
              </tr>   
              <tr><td colspan=9 style="text-align:right"><a href="javascript:" onclick="go_input()"><img src="img/btn_regist.gif" alt="등록" border="0"  /></a> <a href="javascript:" onclick="go_grade()"><img src="img/btn_list.gif" alt="등록" border="0"  /></a></td></tr>            
            </table>
            
            <table class="listTb">
              <tr>
                <th>번호</th>
                <th>&nbsp;등급</th>
                <th>문제번호&nbsp;</th>                
                <th>난이도&nbsp;</th>
                <th>testlet&nbsp;</th>
                <th>등록일&nbsp;</th>                
                <th>관리</th>                
              </tr>
<%              

    if (list!=null && list.size()> 0) {
    	for(int i=0; i<list.size(); i++){
	      map=(HashMap)list.get(i);
	      r_num = CommonUtil.nvl((String)map.get("r_num"));
	      seq = CommonUtil.nvl((String)map.get("seq"));
	      grade = CommonUtil.nvl((String)map.get("grade"));
	      exam_num = CommonUtil.nvl((String)map.get("exam_num"));
	      level_code = CommonUtil.nvl((String)map.get("level_code"));
	      level_name = CommonUtil.nvl((String)map.get("level_name"));
	      testlet = CommonUtil.nvl((String)map.get("testlet"));
	      reg_dt = CommonUtil.nvl((String)map.get("reg_dt"));
%>
			<tr>
                <td><%=r_num %></td>
                <td><%= grade %></td>
                <td><%=exam_num %></td>
                <td><%=level_name %></td>
                <td><%=testlet %></td>
                <td><%=reg_dt %></td>                
                <td><a href="#" onclick="go_modify('<%=seq%>')"><img src="img/btn_mmm.gif" width="16" height="14" alt="manage" /></a> <a href="#" onclick="go_delete('<%=seq%>')"><img src="img/btn_ddd.gif" width="16" height="14" alt="delete" /></a></td>
              </tr>
<%	      
    	}
      
    }else{

%> 
    				<tr>
    	                <td colspan=9 align=center>등록된 등급별 문제난이도가 없습니다.</td>
    	            </tr>
<%
   }
%>
            </table>
            
            <!-- 
            <div class="paging"><a href="#"><img src="img/bt_pprev.gif" alt="이전" /></a><a href="#"><img src="img/bt_prev.gif" alt="이전" /></a><a href="#" class="on">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a><a href="#"><img src="img/bt_next.gif" alt="이전" /></a><a href="#"><img src="img/bt_nnext.gif" alt="이전" /></a></div>
             -->
            <!-- 페이징 -->
            <div class="paging"><common:pagelistnew currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=line_number%>" oneGroup="<%=one_group%>"/></div>
            <!-- //페이징 -->
           <!-- 
            <p class="a_r"><a href="#" onclick="go_input()"><img src="img/btn_regist.gif" alt="등록" width="49" height="20" /></a>&nbsp;&nbsp; </p>
             -->
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="line_number" value="<%=line_number%>">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
